<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>第三种方法</title>
</head>

<body>
  <h4>请写出下面</h4>
  <section class="code">
    <code>var arr=['a', ['b', 'c'], 2, ['d', 'e', 'f'], 'g', 3, 4];flat(arr)//a,b,c,2,d,e,f,g,3,4</code>
    <script type="text/javascript">
      // 方法三：valueOf(格式转换)
      Array.prototype.valueOf = function () {
          return this.join(',');
      };

      var flat = function (arr) {
          return arr + '';
      };

      console.log(flat(['a', ['b', 'c'], 2, ['d', 'e', 'f'], 'g', 3, 4]));


    </script>
  </section>
</body>

</html>
